import common from "../../../lib/common/common.js"
import plugin from "../../../lib/plugins/plugin.js"
import { Restart } from "../../other/restart.js"

let rulePrefix = "((#|\\*)?(星铁|星轨|崩铁|星穹铁道|铁道|sr)|\\*|＊)"
export class upsrjs extends plugin {
  constructor() {
    super({
      name: "图鉴文件更新",
      dsc: "图鉴文件更新",
      event: "message",
      priority: 1,
      rule: [
        {
          reg: `^${rulePrefix}更新图鉴js`,
          fnc: "update",
        },
      ],
    })
  }
  async update(e) {
    await common.downFile(
      "https://gitee.com/rainbowwarmth/StarRail-plugin/raw/alias/alias.js",
      "./plugins/StarRail-plugin/utils/Alias_js.js",
    )
    await this.reply("更新完成，正在进行重启")
    await new Restart(e).restart()
  }
}
